package com.jin.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
 * Created on 2024/6/6.
 * @Description  配置Spring Security
 * @author Zhongyuan Jin
 */
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Bean
    public BCryptPasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/user/**", "/truck/**", "/static/**",
                        "/favicon.ico","/layui/**", "/css/**", "/js/**", "/images/**", "/**/*.ico").permitAll()
                .antMatchers("/","*","/**","layui.css","layui.js","/error.html","/admin.html", "/login.html","/user.html", "/main.js", "/app.css").permitAll()
                .anyRequest().authenticated()
                .and()
                .csrf().disable();
    }
}